{"ast":null,"code":"/* eslint-disable vars-on-top, no-var, prefer-template */\nvar isRegExp = function (re) {\n  return re instanceof RegExp;\n};\nvar escapeRegExp = function escapeRegExp(string) {\n  var reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g,\n    reHasRegExpChar = RegExp(reRegExpChar.source);\n  return string && reHasRegExpChar.test(string) ? string.replace(reRegExpChar, '\\\\$&') : string;\n};\nvar isString = function (value) {\n  return typeof value === 'string';\n};\nvar flatten = function (array) {\n  var newArray = [];\n  array.forEach(function (item) {\n    if (Array.isArray(item)) {\n      newArray = newArray.concat(item);\n    } else {\n      newArray.push(item);\n    }\n  });\n  return newArray;\n};\n\n/**\n * Given a string, replace every substring that is matched by the `match` regex\n * with the result of calling `fn` on matched substring. The result will be an\n * array with all odd indexed elements containing the replacements. The primary\n * use case is similar to using String.prototype.replace except for React.\n *\n * React will happily render an array as children of a react element, which\n * makes this approach very useful for tasks like surrounding certain text\n * within a string with react elements.\n *\n * Example:\n * matchReplace(\n *   'Emphasize all phone numbers like 884-555-4443.',\n *   /([\\d|-]+)/g,\n *   (number, i) => <strong key={i}>{number}</strong>\n * );\n * // => ['Emphasize all phone numbers like ', <strong>884-555-4443</strong>, '.'\n *\n * @param {string} str\n * @param {RegExp|str} match Must contain a matching group\n * @param {function} fn\n * @return {array}\n */\nfunction replaceString(str, match, fn) {\n  var curCharStart = 0;\n  var curCharLen = 0;\n  if (str === '') {\n    return str;\n  } else if (!str || !isString(str)) {\n    throw new TypeError('First argument to react-string-replace#replaceString must be a string');\n  }\n  var re = match;\n  if (!isRegExp(re)) {\n    re = new RegExp('(' + escapeRegExp(re) + ')', 'gi');\n  }\n  var result = str.split(re);\n\n  // Apply fn to all odd elements\n  for (var i = 1, length = result.length; i < length; i += 2) {\n    /** @see {@link https://github.com/iansinnott/react-string-replace/issues/74} */\n    if (result[i] === undefined || result[i - 1] === undefined) {\n      console.warn('reactStringReplace: Encountered undefined value during string replacement. Your RegExp may not be working the way you expect.');\n      continue;\n    }\n    curCharLen = result[i].length;\n    curCharStart += result[i - 1].length;\n    result[i] = fn(result[i], i, curCharStart);\n    curCharStart += curCharLen;\n  }\n  return result;\n}\nmodule.exports = function reactStringReplace(source, match, fn) {\n  if (!Array.isArray(source)) source = [source];\n  return flatten(source.map(function (x) {\n    return isString(x) ? replaceString(x, match, fn) : x;\n  }));\n};","map":{"version":3,"names":["isRegExp","re","RegExp","escapeRegExp","string","reRegExpChar","reHasRegExpChar","source","test","replace","isString","value","flatten","array","newArray","forEach","item","Array","isArray","concat","push","replaceString","str","match","fn","curCharStart","curCharLen","TypeError","result","split","i","length","undefined","console","warn","module","exports","reactStringReplace","map","x"],"sources":["/data/messenger.client/node_modules/react-string-replace/index.js"],"sourcesContent":["/* eslint-disable vars-on-top, no-var, prefer-template */\nvar isRegExp = function (re) { \n  return re instanceof RegExp;\n};\nvar escapeRegExp = function escapeRegExp(string) {\n  var reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g,\n    reHasRegExpChar = RegExp(reRegExpChar.source);\n\n  return (string && reHasRegExpChar.test(string))\n    ? string.replace(reRegExpChar, '\\\\$&')\n    : string;\n};\nvar isString = function (value) {\n  return typeof value === 'string';\n};\nvar flatten = function (array) {\n  var newArray = [];\n\n  array.forEach(function (item) {\n    if (Array.isArray(item)) {\n      newArray = newArray.concat(item);\n    } else {\n      newArray.push(item);\n    }\n  });\n\n  return newArray;\n};\n\n/**\n * Given a string, replace every substring that is matched by the `match` regex\n * with the result of calling `fn` on matched substring. The result will be an\n * array with all odd indexed elements containing the replacements. The primary\n * use case is similar to using String.prototype.replace except for React.\n *\n * React will happily render an array as children of a react element, which\n * makes this approach very useful for tasks like surrounding certain text\n * within a string with react elements.\n *\n * Example:\n * matchReplace(\n *   'Emphasize all phone numbers like 884-555-4443.',\n *   /([\\d|-]+)/g,\n *   (number, i) => <strong key={i}>{number}</strong>\n * );\n * // => ['Emphasize all phone numbers like ', <strong>884-555-4443</strong>, '.'\n *\n * @param {string} str\n * @param {RegExp|str} match Must contain a matching group\n * @param {function} fn\n * @return {array}\n */\nfunction replaceString(str, match, fn) {\n  var curCharStart = 0;\n  var curCharLen = 0;\n\n  if (str === '') {\n    return str;\n  } else if (!str || !isString(str)) {\n    throw new TypeError('First argument to react-string-replace#replaceString must be a string');\n  }\n\n  var re = match;\n\n  if (!isRegExp(re)) {\n    re = new RegExp('(' + escapeRegExp(re) + ')', 'gi');\n  }\n\n  var result = str.split(re);\n\n  // Apply fn to all odd elements\n  for (var i = 1, length = result.length; i < length; i += 2) {\n    /** @see {@link https://github.com/iansinnott/react-string-replace/issues/74} */\n    if (result[i] === undefined || result[i - 1] === undefined) {\n      console.warn('reactStringReplace: Encountered undefined value during string replacement. Your RegExp may not be working the way you expect.');\n      continue;\n    }\n\n    curCharLen = result[i].length;\n    curCharStart += result[i - 1].length;\n    result[i] = fn(result[i], i, curCharStart);\n    curCharStart += curCharLen;\n  }\n\n  return result;\n}\n\nmodule.exports = function reactStringReplace(source, match, fn) {\n  if (!Array.isArray(source)) source = [source];\n\n  return flatten(source.map(function(x) {\n    return isString(x) ? replaceString(x, match, fn) : x;\n  }));\n};\n"],"mappings":"AAAA;AACA,IAAIA,QAAQ,GAAG,UAAUC,EAAE,EAAE;EAC3B,OAAOA,EAAE,YAAYC,MAAM;AAC7B,CAAC;AACD,IAAIC,YAAY,GAAG,SAASA,YAAY,CAACC,MAAM,EAAE;EAC/C,IAAIC,YAAY,GAAG,qBAAqB;IACtCC,eAAe,GAAGJ,MAAM,CAACG,YAAY,CAACE,MAAM,CAAC;EAE/C,OAAQH,MAAM,IAAIE,eAAe,CAACE,IAAI,CAACJ,MAAM,CAAC,GAC1CA,MAAM,CAACK,OAAO,CAACJ,YAAY,EAAE,MAAM,CAAC,GACpCD,MAAM;AACZ,CAAC;AACD,IAAIM,QAAQ,GAAG,UAAUC,KAAK,EAAE;EAC9B,OAAO,OAAOA,KAAK,KAAK,QAAQ;AAClC,CAAC;AACD,IAAIC,OAAO,GAAG,UAAUC,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